/*
 * logging.hpp
 *
 *  Created on: May 27, 2011
 *      Author: jmurray
 */

#ifndef LOGGING_HPP_
#define LOGGING_HPP_

#include <iostream>
#include <iomanip>
#include <fstream>
#include <ctime>
#include <sstream>

using namespace std;

extern ofstream GLOB_LOG_STREAM;

#define logError(s) GLOB_LOG_STREAM << "Line No: " << __LINE__ << \
                   " Function: " << __FUNCTION__ << \
                   " Error: " << s << endl

#define log(s) { \
	time_t * timer=new time_t; \
	struct tm *loc=new struct tm; \
	time(timer); \
	loc=localtime(timer); \
	GLOB_LOG_STREAM << setfill('0') \
					<< setw(4) << loc->tm_year+1900 << "/"  \
	 				<< setw(2) << loc->tm_mon+1  << "/" \
					<< setw(2) << loc->tm_mday << " " \
					<< setw(2) << loc->tm_hour << ":" \
					<< setw(2) << loc->tm_min << ":" \
					<< setw(2) << loc->tm_sec << " " << s << endl << flush; \
}

void init_logging(void);

#endif /* LOGGING_HPP_ */
